# -*- coding:utf8 -*-
# __author__ = "zhangying"
# __date__ = "2019/2/21 10:00"

#自动生成driver

import time
from appium import webdriver
from util.write_user_command import WriteUserCommand


class BaseDriver:
    def android_driver(self,i):
        #devices_name  adb devices  链接模拟器/真机 adb connect 127.0.0.1:21503
        #port  检测端口是否在用  dos_cmd.py
        write_file = WriteUserCommand()
        device = write_file.get_value('user_info_'+str(i),'deviceName')
        port = write_file.get_value('user_info_'+str(i),'port')
        capabilities = {
            "platformName": "Android",
            "deviceName": device,
            "app": "D:\\PythonAppium\\mukewang.apk",
            "appPackage": "cn.com.open.mooc",
            "appActivity": "cn.com.open.mooc.index.splash.MCSplashActivity",
            "noReset": "true"
        }
        driver = webdriver.Remote("http://127.0.0.1:"+port+"/wd/hub", capabilities)
        time.sleep(10)
        return driver

    def ios_driver(self):
        pass

    def get_driver(self):
        pass
